package com.acce.gxsc.page.supervision.makeupCar;

import com.acce.gxsc.model.WorkModel;
import com.acce.gxsc.model.loaclBean.ResultBean;
import com.acce.gxsc.model.netBean.InGoodsBean;
import com.acce.sdk.base.mvp.BasePresenter;
import com.acce.sdk.utils.ToastUtils;

import java.util.ArrayList;

import rx.Subscriber;

/**
 * Created by huxley on 2017/5/26.
 */
public class SupervisionMakeupCarPresenter extends BasePresenter<SupervisionMakeupCarView> {

    public void makeupCar(String diliveryType, String plateNumG, String plateNumX, String containNo, String hangNum, String contactName,
                          String underCompany, ArrayList<InGoodsBean> pregistergoods, String fee2Id, String fee3Id, String superviseRemarks, String createTime) {
        WorkModel.getInstance().makeupCar(diliveryType, plateNumG, plateNumX, containNo, hangNum, contactName, underCompany,
                pregistergoods, fee2Id, fee3Id, superviseRemarks, createTime).subscribe(new Subscriber<ResultBean<Object>>() {
            @Override
            public void onStart() {
                if (mViewRef != null) {
                    getView().showProgressDialog("补录中...", false);
                }
            }

            @Override
            public void onNext(ResultBean<Object> datas) {
                if (mViewRef != null) {
                    ToastUtils.show(datas.returnMsg);
                    getView().makeupCarSuccess();
                }
            }

            @Override
            public void onCompleted() {
                if (mViewRef != null) {
                    getView().hideProgressDialog();
                }
            }

            @Override
            public void onError(Throwable e) {
                if (mViewRef != null) {
                    e.printStackTrace();
                    ToastUtils.show("处理失败！");
                    getView().hideProgressDialog();
                }
            }
        });
    }
}
